package com.guoguo.utils.aliOss;

import com.guoguo.enums.AliOssImageEnum;
import com.guoguo.utils.PropertyUtils;

/**
 * Created by Administrator on 2017/10/26 0026.
 */

     /*
                           _ooOoo_
                          o8888888o
                          88" . "88
                          (| -_- |)
                          O\  =  /O
                       ____/`---'\____
                     .'  \\|     |//  `.
                    /  \\|||  :  |||//  \
                   /  _||||| -:- |||||-  \
                   |   | \\\  -  /// |   |
                   | \_|  ''\---/''  |   |
                   \  .-\__  `-`  ___/-. /
                 ___`. .'  /--.--\  `. . __
              ."" '<  `.___\_<|>_/___.'  >'"".
             | | :  `- \`.;`\ _ /`;.`/ - ` : | |
             \  \ `-.   \_ __\ /__ _/   .-` /  /
        ======`-.____`-.___\_____/___.-`____.-'======
                           `=---='
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 佛祖保佑       永无BUG
        */
public class AliOssImageConfigUtils {

    /**
     * 水印
     *
     * @param image
     * @param text
     * @param type
     * @return
     */
    public static AliOssImageConfig getWaterMark(String image, String text, String type) {
        AliOssImageConfig aliOssImageConfig = new AliOssImageConfig();
        aliOssImageConfig.setHandleType(AliOssImageEnum.ALI_HANDLE_WATERMARK.getId());
        aliOssImageConfig.setTransparency(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.transparency")));
        aliOssImageConfig.setPositionType(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.positionType")));
        aliOssImageConfig.setX(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.x")));
        aliOssImageConfig.setY(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.y")));
        aliOssImageConfig.setVoffset(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.voffset")));
        aliOssImageConfig.setImage(image);
        aliOssImageConfig.setText(text);
        aliOssImageConfig.setType(type);
        aliOssImageConfig.setColor(PropertyUtils.getProperty("alioss_image_config.properties", "wm.color"));
        aliOssImageConfig.setSize(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.size")));
        aliOssImageConfig.setShadow(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.shadow")));
        aliOssImageConfig.setRotate(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.rotate")));
        aliOssImageConfig.setFill(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.fill")));
        aliOssImageConfig.setOrder(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.order")));
        aliOssImageConfig.setAlign(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.align")));
        aliOssImageConfig.setInterval(Integer.parseInt(PropertyUtils.getProperty("alioss_image_config.properties", "wm.interval")));
        return aliOssImageConfig;
    }

    /**
     * 自定义样式
     *
     * @param styleName
     * @return
     */
    public static AliOssImageConfig getStyle(String styleName) {
        AliOssImageConfig aliOssImageConfig = new AliOssImageConfig();
        aliOssImageConfig.setStyleName(styleName);
        return aliOssImageConfig;
    }

    /**
     * 旋转
     *
     * @param angle
     * @return
     */
    public static AliOssImageConfig getRotate(int angle) {
        AliOssImageConfig aliOssImageConfig = new AliOssImageConfig();
        aliOssImageConfig.setAngle(angle);
        return aliOssImageConfig;
    }

    /**
     * 压缩
     *
     * @param proportion 等比例压缩
     * @param resizeType 压缩类型
     * @param height     高
     * @param width      宽
     * @return
     */
    public static AliOssImageConfig getResize(int proportion, int resizeType, int height, int width) {
        AliOssImageConfig aliOssImageConfig = new AliOssImageConfig();
        aliOssImageConfig.setProportion(proportion);
        aliOssImageConfig.setResizeType(resizeType);
        aliOssImageConfig.setHeight(height);
        aliOssImageConfig.setWidth(width);
        return aliOssImageConfig;
    }

    /**
     * 改变格式
     *
     * @param formatType
     * @return
     */
    public static AliOssImageConfig getFormate(String formatType) {
        AliOssImageConfig aliOssImageConfig = new AliOssImageConfig();
        aliOssImageConfig.setFormatType(formatType);
        return aliOssImageConfig;
    }
}
